package com.zzx.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.zzx.exception.CustomException;
import com.zzx.mapper.ItemsMapper;
import com.zzx.mapper.ItemsMapperCustom;
import com.zzx.po.Items;
import com.zzx.po.ItemsCustom;
import com.zzx.po.ItemsQueryVo;
import com.zzx.service.ItemsService;

public class ItemsServiceImpl implements ItemsService {

	@Autowired
	private ItemsMapperCustom mapper;
	
	@Autowired
	private ItemsMapper itemsMapper;
	
	@Override
	public List<Items> findItemList(ItemsQueryVo itemsQueryVo) {
		return mapper.findItemList(itemsQueryVo);
		
	}
	@Override
	public ItemsCustom findItemById(Integer id) throws Exception {
		Items items = itemsMapper.selectByPrimaryKey(id);
		if (items==null) {
			throw new CustomException("信息不存在");
		}
		ItemsCustom custom = new ItemsCustom();
		BeanUtils.copyProperties(items, custom);
		
		return custom;
	}
	@Override
	public void updateItem(Integer id,ItemsCustom itemsCustom) throws Exception {
		if (id == null) {
			
		}
		itemsCustom.setId(id);
		itemsMapper.updateByPrimaryKeyWithBLOBs(itemsCustom);
	}

}
